package leetcode.weekly.week309;

//Solution3Test
public class Solution3 {

	public int longestNiceSubarray(int[] nums) {
		int l = 0, r = 0, len = nums.length;
		int ans = 1, in = 0;
		while (r < len) {
			int cur = nums[r];
			while (l < r && (cur & in) != 0) {
				in ^= nums[l++];
			}
			ans = Math.max(ans, r - l + 1);
			in |= cur;
			r++;
		}
		return ans;
	}

	public static void main(String[] args) {
		System.out.println(Integer.toBinaryString(3));
		System.out.println(Integer.toBinaryString(8));
		System.out.println(Integer.toBinaryString(48));
	}
}
